package org.grow.preview.infrastructure;

import org.grow.preview.controller.dto.PureStudent;
import org.grow.preview.domain.Group;
import org.grow.preview.domain.Student;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface JpaStudent extends JpaRepository<Student,Long> {

    Student findByStudentCode(String code);

    //Student findByGroup_GroupCode(String code);
    @Query("select new org.grow.preview.controller.dto.PureStudent(s.studentCode,s.basicInfo) from Student s left join s.group g where g.groupCode = ?1")
    List<PureStudent> findByGroup_GroupCode(String code);

}
